#!/usr/bin/env python
# -*- coding:utf-8 -*-
__author__ = 'walkingsky tangxn_1@163.com'

from models.config import Config
from models.excel_lib import read_excel ,write_excel
import time
import os
import re

class Log:

    def __init__(self):
        config = Config()
        self.log_path = config.get_log_path()
        
        
    def set_log_file(self,file):
        print(self.log_path)
        print(file)
        self.log_file = self.log_path + '\\' + file


    def write_log(self,row):
        file = re.sub(r'\.xlsx$','.xls',self.log_file,1)
        #print(file)
        if not os.path.exists(file):
            write_excel(self.log_file,['case_id','操作','操作说明','执行结果','时间'])

        row.append(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
        write_excel(self.log_file,row)

        